package pjkanri.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;

import pjkanri.entity.Issure;
import pjkanri.entity.Issure_detail;

public class Issure_DetailDAO {
	
	/**
	 * 	全件検索
	 * @return
	 */
	public static List<Issure_detail> findAll(){
		
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		
		Criteria criteria = session.createCriteria(Issure_detail.class);
		List<Issure_detail> issue_detaillist = criteria.list();
		
		return issue_detaillist;
	}
	
	/**
	 * 	追加
	 * 
	 * @param issue_detail
	 * @return
	 * @throws DAOException
	 */
	public static int insert(Issure_detail issue_detail) throws DAOException {
		
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		
		System.out.println(issue_detail.getIssure_id());
		
		Criteria criteria = session.createCriteria(Issure_detail.class);
		List<Issure> issueList = criteria.list();

		issue_detail.setIssure_id(issueList.size());
		
		System.out.println(issue_detail.getIssure_id());
		
		session.save(issue_detail);
		
		return 0;
	}
	
}
